<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="formDate.uname" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model.number="formDate.age" /><br /><br />

      <label>身高：</label>
      <input type="number" v-model.number="formDate.m" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model.number="formDate.kg" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="formDate.History" /><br /><br />

      <button @click.prevent="submit">诊断</button>
    </form>

    <p>患者 的诊断结果：{{ text }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formDate: {
        uname: "",
        age: "",
        m: "",
        kg: "",
        History: "",
      },
      bmiH: "", //身高
      text: "",
    };
  },
  methods: {
    submit() {
      // console.log(1);
      this.bmiH = this.formDate.kg / (this.formDate.m * this.formDate.m);
      
      if (this.bmiH >= 25) {
        this.text = "体重过重";
      } else if (this.bmiH < 18.5) {
        this.text = "体重过轻";
      } else {
        this.text = "体重正常";
      }
      console.log(this.bmiH);
    },
  },
};
</script>

